package com.freedom.auth.controller;

import com.freedom.auth.service.ILoginService;
import com.freedom.auth.vo.LoginVO;
import com.freedom.base.util.AjaxResult;
import com.freedom.org.domain.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author freedom
 */
@RestController
@RequestMapping("/login")
public class LoginController {
  @Autowired
  private ILoginService loginService;

  @PostMapping
    public AjaxResult login( @RequestBody Employee employee ){
      try {
          LoginVO login = loginService.login(employee);
          return AjaxResult.success(login,"登录成功");
      } catch (Exception e) {
          e.printStackTrace();
          return AjaxResult.error("登陆失败");
      }
  }

}
